package cn.tedu.duotai;

public class PetDemo {
    public static void main(String[] args) {
        //创建Master的对象
//        Master master = new Master();
//        System.out.println(master);//cn.tedu.duotai.Master@28d93b30
//        System.out.println(master.pet);//null
//        //买了一只宠物猫
//        Cat cat = new Cat();
//       // Pet cat = new Cat();
//        cat.name = "小花";
//        cat.age = 1;
//        //cat 属于 master对象的
//        master.pet = cat;//向上造型
//        System.out.println(master.pet);//cn.tedu.duotai.Cat@1b6d3586
//        System.out.println(master.pet.name);//"小花"
//
//        //
//        Master master1 = new Master();
//        Dog dog = new Dog();
//        dog.name = "白白";
//        dog.age = 2;
//        master1.pet = dog;
//        //获取Master1对象的宠物的名称时
//        System.out.println(master1.pet.name);

        //测试Pet类型为方法参数
//        PetShop shop = new PetShop();
//        shop.name = "爱宠物宠物店";
//        //宠物对象
//        Cat cat = new Cat();
//        cat.name = "猫咪";
//        cat.age = 2;
//        shop.sell(cat);
//        //要卖出一只狗
//        Dog dog = new Dog();
//        dog.name = "狗狗";
//        dog.age = 3;
//        shop.sell(dog);

        PetShop shop = new PetShop();
        shop.name = "爱宠物宠物店";
//        //查询所有的宠物猫
//        shop.showCats();
//        //查询所有的宠物狗
//        shop.showDogs();
        //查询所有的宠物
        shop.showPets();

    }
}
